﻿
@{
    ViewBag.Title = "我的文章";
    Layout = "~/Views/Shared/_Member.cshtml";
}

<div class="row p10 bcolor" style="overflow:auto;">
    <div class="row plr10">
        <a href="/Member/DiscussEdit@(ViewBag.Suffix)" class="layui-btn layui-btn-normal">发布新讨论</a>
    </div>
    <hr />
    <div id="dot_article"></div>

    <script id="dot_tmp_article" type="text/x-dot-template">
        {{? it.length }}

        {{ for(var idx in it) { if(it[idx].ID) { var elm = it[idx]; }}
        <div class="row p5p10p10p10 oa" {{= (idx != 0 ? 'style="border-top:1px #E6E6E6 solid;"' : '')}}>
            <div class="layui-col-md12 pt20">
                <div class="layui-col-md11 pb10">
                    <div class="layui-col-md12">
                        <div class="new-panle">
                            <a href="javascript:void(0)">
                                <div class="panle-title ahover">{{= elm.Title }}</div>
                            </a>
                            {{? elm.SpecialName }}
                            <div style="padding:5px 0 2px 0;color:#9F9F9E;">专题：{{= elm.SpecialName }}</div>
                            {{? }}
                            <div class="panle-info">
                                <span>
                                    <i class="layui-icon">&#xe637;</i> {{= new Date(elm.CreateTime).format('yyyy-MM-dd hh:mm') }}
                                </span>
                                <span>
                                    <i class="layui-icon">&#xe615;</i> {{= elm.ClickAmount }}
                                </span>
                            </div>
                            <div class="pt10" style="color:#9F9F9E;">
                                {{= elm.Content }}
                            </div>
                            <div class="panle-content">
                                {{? elm.Audit == '@((int)QunProject.Model.EnumHelper.AuditType.待审核)' }}
                                <span class="blue">待审核</span>
                                {{?? elm.Audit == '@((int)QunProject.Model.EnumHelper.AuditType.审核通过)' }}
                                <span class="green">审核通过</span>
                                {{?? elm.Audit == '@((int)QunProject.Model.EnumHelper.AuditType.审核不通过)' }}
                                <span class="red">审核不通过</span>
                                <span style="padding-top:2px;">（原因：{{= elm.AuditReason }}）</span>
                                {{?? }}
                                <span class="gray">未知状态</span>
                                {{? }}
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md12 pt10">
                        <div class="new-panle">
                            {{? elm.Audit == '@((int)QunProject.Model.EnumHelper.AuditType.待审核)' }}
                            <a href="/member/DiscussEdit/{{= elm.ID }}@(ViewBag.Suffix)" class="href">编辑</a>
                            <a href="javascript:void(0)" onclick="javascript: { deleteArt({{= elm.ID }}); }" class="href pl20">删除</a>
                            {{?? elm.Audit == '@((int)QunProject.Model.EnumHelper.AuditType.审核通过)' }}
                            <a href="/article/Info/{{= elm.ID }}@(ViewBag.Suffix)" class="href" target="_blank">查看</a>
                            <a href="/member/DiscussEdit/{{= elm.ID }}@(ViewBag.Suffix)" class="href pl20">编辑</a>
                            <a href="javascript:void(0)" onclick="javascript: { deleteArt({{= elm.ID }}); }" class="href pl20">删除</a>
                            {{?? elm.Audit == '@((int)QunProject.Model.EnumHelper.AuditType.审核不通过)' }}
                            <a href="/member/DiscussEdit/{{= elm.ID }}@(ViewBag.Suffix)" class="href">编辑</a>
                            <a href="javascript:void(0)" onclick="javascript: { deleteArt({{= elm.ID }}); }" class="href pl20">删除</a>
                            {{?? }}
                            <span class="gray">此文章状态错误</span>
                            {{? }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {{ } } }}
        {{?? }}
        <div class="row p20p10 bcolor oa">{{= noDataTitle }}</div>
        {{? }}
    </script>
    <div id="page" class="row p20p10 oa tcenter"></div>
</div>

<script>
    var article = new Article();
    $(function () {
        article.getdata();
    });

    ; function Article() {
        this.paras = {
            page: 1,
            rows: 10,
            count: 0
        };
        this.option = {
            elem: 'page'
        };
        this.getdata = function (isLoad, next) {
            if (isLoad) { this.paras.page = next; }
            var this_obj = this;
            $.post('/member/GetMemberDiscussListResult', this_obj.paras, function (result) {
                this_obj.paras.count = result.count;
                if (!isLoad) { this_obj.setpage(); }
                if (result.succ) {
                    var dotTmp = doT.template($("#dot_tmp_article").text());
                    $("#dot_article").html(dotTmp(result.data));
                } else {
                    layer.msg(result.msg);
                }
            });
        };
        this.setpage = function () {
            var this_obj = this;
            layui.laypage.render({
                elem: this_obj.option.elem,
                count: this_obj.paras.count,
                limit: this_obj.paras.rows,
                theme: '#3499DB',
                layout: ['count', 'prev', 'page', 'next'],
                jump: function (obj, first) {
                    if (!first) {
                        var index = obj.curr;
                        this_obj.getdata(true, index);
                    }
                }
            });
        };
    };

    function deleteArt(id) {
        var confirmWin = layer.confirm('确定删除此讨论吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            //此处添加执行过程
            layer.close(confirmWin);
            $.post('/member/DeleteMemberArticleResult', { articleId: id }, function (result) {
                article.getdata();
            });
        }, function () {
            layer.close(confirmWin);
        });

    };

</script>